package com.lp.biz.operations.controller;

import com.lp.biz.operations.model.vo.BenefitsAdd;
import com.lp.biz.operations.service.BizBenefitsService;
import com.lp.common.annotation.PermissionAnnotation;
import com.lp.common.entity.PageParams;
import com.lp.common.utils.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import static com.lp.common.constant.MenuConstant.BENEFITS;

/**
 * BizBenefitsController
 * @program: backend
 * @author Ke.Song
 * @since 2024-09-03 23:54:13
 */
@RestController
@RequestMapping("/benefits")
public class BizBenefitsController {

    @Autowired
    private BizBenefitsService benefitsService;

    /**
     * 获取权益可选内容
     * @return 查询结果
     */
    @GetMapping("/content")
    @PermissionAnnotation(menus = {BENEFITS})
    public CommonResult getContentList() {
        return benefitsService.getContentList();
    }

    /**
     * 开通权益
     * @param params 开通参数
     * @return 处理结果
     */
    @PostMapping
    @PermissionAnnotation(menus = {BENEFITS})
    public CommonResult addBenefits(@RequestBody @Validated BenefitsAdd params) {
        benefitsService.addBenefits(params);
        return CommonResult.success();
    }

    /**
     * 获取开通列表
     * @param query 查询参数
     * @return 查询结果
     */
    @GetMapping
    @PermissionAnnotation(menus = {BENEFITS})
    public CommonResult getBenefits(PageParams query) {
        return benefitsService.getBenefits(query);
    }

}
